#include<bits/stdc++.h>
using namespace std;
int n, k;
vector<int>t[20];
int ans;
int flag[20], dep[20], fa[20];
void dfs(int now){
    if(dep[now] % k == 1)flag[now] = 1;
    for(auto to : t[now]){
        if(!dep[to]){
            dep[to] = dep[now] + 1;
            fa[to] = now;
            dfs(to);
        }
    }
}
int num[20][20];
int dist[20][20];
int vis[20][20];
void get(int x, int y){
    if(x == y){
        vis[x][y] = 1;
        dist[x][y] = 0;
        num[x][y] = flag[x];
        return;
    }
    if(vis[x][y])return;
    if(dep[x] < dep[y]){
        get(x, fa[y]);
        vis[x][y] = 1;
        dist[x][y] = dist[x][fa[y]] + 1;
        num[x][y] = num[x][fa[y]] + flag[y];
    }else{
        get(fa[x], y);
        vis[x][y] = 1;
        dist[x][y] = dist[fa[x]][y] + 1;
        num[x][y] = num[fa[x]][y] + flag[x];
    }
}
bool chk(){
    memset(vis, 0, sizeof(vis));
    int ok = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            get(i,j);
            if(dist[i][j] != k-1)continue;
            if(num[i][j] != 1)return 0;
        }
    }
    return 1;
}
signed main(){
    freopen("life.in", "r", stdin);
    freopen("life.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n >> k;
    if(n <= 18){
        for(int i = 1; i < n; i++){
            int u, v;
            cin >> u >> v;
            t[u].emplace_back(v);
            t[v].emplace_back(u);
        }
            memset(dep, 0, sizeof(dep));
            memset(flag, 0, sizeof(flag));
            dep[1] = 1;
            dfs(1);
        // for(int i = 1; i <= n; i++){
        for(int i = 0; i < (1<<n); i++){
            for(int j = 1; j <= n; j++){
                flag[j] = i>>j-1&1;
            }
            ans += chk();
            // int ok = 1;
            // for(int j = 1; j <= n; j++){
            //     if(flag[j] && j < i){
            //         ok = 0;
            //     }
            // }
            // if(ok && chk())ans++;
        }
    }else{
        ans = k;
    }
    if(ans){
        cout << "YES" << '\n' << ans << '\n';
    }else{
        cout << "NO" << '\n' << ans << '\n';
    }
    return 0;
}